﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Agile.DataAccess
{
    /// <summary>
    /// 
    /// </summary>
    public interface ISelectBuilder<TEntity>
    {
        /// <summary>
        /// 
        /// </summary>
        SelectBuilderData Data { get; set; }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="currentPage"></param>
        /// <param name="itemsPerPage"></param>
        /// <returns></returns>
        ISelectBuilder<TEntity> Paging(int currentPage, int itemsPerPage);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="columnName"></param>
        /// <param name="value"></param>
        /// <param name="parameterType"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        ISelectBuilder<TEntity> OrderBy(string columnName, string value, DataTypes parameterType = DataTypes.Object, int size = 0);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="columnName"></param>
        /// <param name="value"></param>
        /// <param name="parameterType"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        ISelectBuilder<TEntity> Where(string columnName, object value, DataTypes parameterType = DataTypes.Object, int size = 0);

   /// <summary>
        /// 执行SQL查询语句并返回List集合
   /// </summary>
   /// <param name="customMapper"></param>
   /// <returns></returns>
        List<TEntity> QueryMany(Action<TEntity, IDataReader> customMapper = null);
        /// <summary>
        /// 执行SQL查询语句并返回List集合
        /// </summary>
        /// <param name="customMapper"></param>
        /// <returns></returns>
        List<TEntity> QueryMany(Action<TEntity, dynamic> customMapper);
        /// <summary>
        /// 执行SQL查询语句并返回List集合
        /// </summary>
        /// <typeparam name="TList"></typeparam>
        /// <param name="customMapper"></param>
        /// <returns></returns>
        TList QueryMany<TList>(Action<TEntity, IDataReader> customMapper = null) where TList : IList<TEntity>;
        /// <summary>
        /// 执行SQL查询语句并返回List集合
        /// </summary>
        /// <typeparam name="TList"></typeparam>
        /// <param name="customMapper"></param>
        /// <returns></returns>
        TList QueryMany<TList>(Action<TEntity, dynamic> customMapper) where TList : IList<TEntity>;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="list"></param>
        /// <param name="customMapper"></param>
        void QueryComplexMany(IList<TEntity> list, Action<IList<TEntity>, IDataReader> customMapper);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="list"></param>
        /// <param name="customMapper"></param>
        void QueryComplexMany(IList<TEntity> list, Action<IList<TEntity>, dynamic> customMapper);
        /// <summary>
        /// 执行SQL查询语句并返回单个T对象
        /// </summary>
        /// <param name="customMapper"></param>
        /// <returns></returns>
        TEntity QuerySingle(Action<TEntity, IDataReader> customMapper = null);
        /// <summary>
        /// 执行SQL查询语句并返回单个T对象
        /// </summary>
        /// <param name="customMapper"></param>
        /// <returns></returns>
        TEntity QuerySingle(Action<TEntity, dynamic> customMapper);
        /// <summary>
        /// 执行SQL查询语句并返回单个T对象
        /// </summary>
        /// <param name="customMapper"></param>
        /// <returns></returns>
        TEntity QueryComplexSingle(Func<IDataReader, TEntity> customMapper);
        /// <summary>
        /// 执行SQL查询语句并返回单个T对象
        /// </summary>
        /// <param name="customMapper"></param>
        /// <returns></returns>
        TEntity QueryComplexSingle(Func<dynamic, TEntity> customMapper);
    }
}
